package day04;

import day04.pojo.Category;
import day04.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ColumnListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.junit.Test;

import java.util.List;

public class Demo04BeanHandler {
    @Test
    public  void BeanHandler() throws Exception{
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());
        String sql ="select *  from category ";
        List<String> cid = queryRunner.query(sql, new ColumnListHandler<String>("cname"));
        System.out.println(cid);
    }
}
